package com.atguigui.leetcode;

/**
 * 1678.设计 Goal 解析器
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by  wangjiaxin  on 2022/11/6 22:34
 */
public class P1678GoalParserInterpretation {

    public static void main(String[] args) {
        Solution solution = new P1678GoalParserInterpretation().new Solution();
        String str = "G()(al)";
        System.out.println(solution.interpret(str));
        // TO TEST
    }

    class Solution {
        public String interpret(String command) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < command.length(); i++) {
                if ('G' == command.charAt(i)) {
                    sb.append("G");
                } else if ('(' == command.charAt(i) && ')' == command.charAt(i + 1)) {
                    sb.append("o");
                    i++;
                } else {
                    sb.append("al");
                    i += 3;
                }
            }

            return sb.toString();
        }
    }
}
